package demo.partten.flyweight.patten;

import demo.partten.flyweight.patten.Example;

import java.util.HashMap;
import java.util.Map;

/**
 * 利用静态代码块实现享元模式 利用类加载过程持久化到内存,使用时直接调用即可
 */
public class ShapeFactory {

    private static final Map<String,String> values = new HashMap<>();
    public static final Example example = new Example();

    static {
        values.put("key","value");
        example.setName("LiLei");
    }

    public static String getValue(String key) {
        return values.get(key);
    }

}
